<?php
	function displayMain($userAnn) {
?>			

			<table class="cadreann" style="width:100%">
				<tr>
					<td style="width:5%"><input name='checher' type='checkbox' value='checker'></td>
					<td style="width:10%">Date</td>
					<td style="width:30%">Titre</td>
					<td style="width:15%">D&eacute;part</td>
					<td style="width:15%">Destination</td>
					<td style="width:10%">Prix</td>
					<td style="width:15%">Actions</td>
				</tr>
			</table>
			<?php 
				if($userAnn != null) {
					foreach($userAnn as $ann){
						$annid = $ann['ANN_ID'];
						$anntitre = $ann['ANN_TITRE'];
						
						echo '<div class="cadresoustype">';
						echo '<table style="width:100%">';
						echo "<tr>";
						echo 	"<td style=\"width:5%\"><input name='checher' type='checkbox' value='checker'></td>";
						echo 	"<td style=\"width:10%\">". date("d/m/Y", strtotime($ann['ANN_DATE_CREA']))."</td>";
						echo 	"<td style=\"width:30%\">".trimRight($ann['ANN_TITRE'])."</td>";
						echo 	"<td style=\"width:15%\">".$ann['ANN_VILLE_DEP']."</td>";
						echo 	"<td style=\"width:15%\">".$ann['ANN_VILLE_ARR']."</td>";
						echo 	"<td style=\"width:10%\">".$ann['ANN_PRIX']."</td>";
						echo 	"<td style=\"width:15%\">
									<a href=\"javascript:ConfirmDeleteAnnonce('".$ann['ANN_ID']."', '".$_SESSION["tokena"]."');\">
										<img src=\"view/design/images/common/trash.gif\" title=\"Supprimer\">
									</a>
									&nbsp;&nbsp;
									<img src=\"view/design/images/common/edit.png\" title=\"Editer\">
									&nbsp;&nbsp;
									<a href=\"?content=annonce&edit=true&ann=$annid&annonce=$anntitre\"><img src=\"view/design/images/common/zoomin.png\" title=\"Cliquer pour voir le d&eacute;tail\"></a>
								</td>";
						echo "</tr>";
						echo "</table>";
						echo '</div>';

					}
				}else {
					echo '<span class="normal"><p />Vous n\'avez pas d\'annonces</span>';
				}
			?>	
<?php			
	}
	include(dirname(__FILE__) . '../../view/menu.php');
	displayMain($userAnn);
?>	

<?php 
	function trimRight($toTrim) {
		if (!empty($toTrim)) {
			
			return ucfirst(strtolower($toTrim));
		}
		return "";	
	}
?>